<script>
export default {
  name: "XunjianView",
  data() {
    return {
      list: []
    }
  },
  methods: {
    onBack() {
      this.$router.go(-1);
    },
    findAll() {
      this.axios.get(`http://localhost:9999/api-work-order-service/work-order/qcAll`).then(res => {
        this.list = res.data.data;
        console.log(res)
      })
    },
    handleTicket(id) {
      this.$router.push({ path: '/xunjianxq', query: { id:id } })
    },
    handleTicket1(id) {
      this.$router.push({ path: '/xunjianxqz', query: { id:id } })
    }
  },
  created() {
    this.findAll();
  }
}
</script>

<template>
<div>
  <!-- 顶部导航栏 -->
  <van-nav-bar
      title="巡检计划"
      left-arrow
      @click-left="onBack"
      fixed
  />
  <h3>占位</h3>
  <!-- 列表 -->
  <div class="ticket-list">
    <div v-for="ticket in list" :key="ticket.id" class="ticket-item">
      <div class="ticket-header">
        <div class="ticket-id">计划名称：{{ ticket.name }}</div>
      </div>
      <div class="ticket-content">
        <div class="ticket-info">
          <div class="ticket-header">计划类别：{{ ticket.type==1?'人工巡检' : '智能巡检' }}</div>
          <div class="ticket-header">计划类别：{{ ticket.status==1?'启用' : '禁用' }}</div>
          <div class="ticket-id">持续时间：{{ ticket.chixuntime }}</div>
        </div>
        <div class="ticket-actions">
          <van-button square v-if="ticket.type==1" type="primary" size="small" @click="handleTicket(ticket.id)">查看</van-button>
          <van-button square v-if="ticket.type==2" type="primary" size="small" @click="handleTicket1(ticket.id)">查看</van-button>
        </div>
      </div>
    </div>
  </div>
</div>
</template>

<style scoped>
.ticket-item {
  background-color: #fff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.ticket-item {
  background-color: #fff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #ebedf0;
}

.ticket-id {
  font-size: 14px;
  color: #323233;
}

.ticket-priority {
  font-size: 14px;
  font-weight: 500;
}

.ticket-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ticket-info {
  font-size: 13px;
  color: #646566;
  line-height: 1.5;
}

:deep(.van-button--primary) {
  background-color: #1989fa;
  border-color: #1989fa;
}

:deep(.van-button--success) {
  background-color: #07c160;
  border-color: #07c160;
}
</style>